﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RBAC_Uthorization.Read.API.Application.Command.OffIcCommand;
using RBAC_Uthorization.Read.API.DTO;
using RBAC_Uthorization.Read.API.DTO.Response.offlc;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;


namespace RBAC_Uthorization.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [Authorize]
    [ApiController]
    public class OfflcController : ControllerBase
    {
        private readonly IMediator _mediator;
        private readonly ILogger<OfflcController> _logger;

        public OfflcController(IMediator mediator, ILogger<OfflcController> logger)
        {
            _mediator = mediator;
            _logger = logger;
        }
        /// <summary>
        /// 下拉框显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<offlcSelectShowDto>>> SelectOfflc()
        {
            return await _mediator.Send( new OfflcSelectShowCommand() {
                offlc_id = HttpContext.User.FindFirst(JwtRegisteredClaimNames.Sid)?.Value }
                
            );
        }
    }
}
